﻿using System;
using System.Windows;
using Csla.Xaml;
using Accounting.Library;

namespace csla4Skeleton.UI.SL.NghiepVu.Kho.K_PhieuNhapKho
{
    public partial class K_PhieuNhapKho_ListViewModel : ViewModel<K_PhieuNhapKhoList>
    {

        public K_PhieuNhapKho_ListViewModel(string mode)
        {
            BeginRefresh("GetK_PhieuNhapKhoList", mode);

        }
        
        public void GetK_PhieuNhapKho_ListViewModel(string mode)
        {
            BeginRefresh("GetK_PhieuNhapKhoList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(K_PhieuNhapKhoInfo), typeof(K_PhieuNhapKho_ListViewModel), null);
        public K_PhieuNhapKhoInfo SelectedItem
        {
            get { return (K_PhieuNhapKhoInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteK_PhieuNhapKho(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                Accounting.Library.K_PhieuNhapKho.DeleteK_PhieuNhapKho(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetK_PhieuNhapKhoList",BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }	
    }
}
